<?php
namespace Admin\Controller;

use Think\Controller;

class IndexController extends CommonController
{
    public function index()
    {
        $nav = $this->navAuth();
        $title = '欢迎'.$_SESSION['aname'].'进入仿layui社区后台管理平台';
        $this->assign('nav', $nav);
        $this->assign('title', $title);
        $this->display();
    }

    public function welcome()
    {
        $admin_login = M('log')->where('type="5"')->field('ip,time')->order('id desc')->select();
        $login_time = count($admin_login);
        $last_login['ip'] = $admin_login[0]['ip'];
        $last_login['time'] = timeFormat($admin_login[0]['time']);
        $server_info = [
            '服务器操作系统'=>PHP_OS,
            '系统版本'=>php_uname('r'),
            '当前系统用户名'=>Get_Current_User(),
            '运行环境'=>$_SERVER["SERVER_SOFTWARE"],
            'PHP版本'=>PHP_VERSION,
            'ThinkPHP版本'=>THINK_VERSION,
            '主机名'=>$_SERVER['SERVER_NAME'],
            '服务器域名'=>$_SERVER["HTTP_HOST"],
            '服务器IP'=>GetHostByName($_SERVER['SERVER_NAME']),
            '服务器端口'=>$_SERVER['SERVER_PORT'],
            '服务器的语言种类'=>$_SERVER["HTTP_ACCEPT_LANGUAGE"],
            '网站所在录'=>$_SERVER["DOCUMENT_ROOT"],
            '浏览器信息'=>substr($_SERVER['HTTP_USER_AGENT'], 0, 40),
            '通信协议'=>$_SERVER['SERVER_PROTOCOL'],
            '上传附件限制'=>ini_get('upload_max_filesize'),
            '执行时间限制'=>ini_get('max_execution_time').'秒',
            '服务器时间'=>date("Y年n月j日 H:i:s"),
            '北京时间'=>gmdate("Y年n月j日 H:i:s", time()+8*3600),
            '剩余空间'=>round((disk_free_space(".")/(1024*1024)), 2).'M',
            ];
        $admins = M('admin')->field('aname')->select();
        $users = M('users')->field('uname')->select();
        $this->assign('last_login', $last_login);
        $this->assign('login_time', $login_time);
        $this->assign('server_info', $server_info);
        $this->assign('admins', count($admins));
        $this->assign('users', count($users));
        $this->display();
    }

    public function close()
    {
        $this->display();
    }
}
